import sys
from PySide import QtGui

class LedWidget(QtGui.QWidget):
	def __init__(self, parent = None):
		QtGui.QWidget.__init__(self, parent)
		
		self.stateOn = False
		self.label = QtGui.QLabel("Homed", self)
		self.label.move(2, 2)
		self.setGeometry(0, 0, 64, 64) 
		
	def paintEvent(self, event):
		qp = QtGui.QPainter()
        	qp.begin(self)
        	self.drawWidget(qp)
       		qp.end()
		
	def drawWidget(self, qp):
		size = self.size()
		width = size.width()
		height = size.height()
		
		qp.setPen(QtGui.QColor(255, 255, 255))
		if self.stateOn == False:
            		qp.setBrush(QtGui.QColor(255, 0, 0))
            	elif self.stateOn == True:
            		qp.setBrush(QtGui.QColor(0, 255, 0))
            			
            	qp.drawRect(16, 16, width - 36, height - 36)
            	
        def setState(self, state):
        	self.stateOn = state
        	self.repaint()
        
